<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>元素选择器</title>
		<style>
			*{
				font-size: 14px;
				font-family: "微软雅黑";
			}
			div{
				border: 1px solid red;
				width: 150px;
				height: 100px;
				margin: 15px;
				text-align: center;
				line-height: 100px;
			}
			
			.scott-user-submit{
				margin: 15px;
				color: white;
				background-color: #ef5b00;
				height: 50px;
				line-height: 50px;
				text-align: center;
				width: 45%;
				display: block;
				cursor: pointer;
				font-size: 14px;
				font-family: "Microsoft YaHei";
				
				/*去掉边框的关键代码*/
				border: 0 none;
			}
			
			.bg{
				background-color: green;
			}
		</style>
	</head>
	<body>
			
		<div id="king">
			刘备
		</div>
		<div>
			关羽
		</div>
		<div>
			张飞
		</div>
		
		<input class="scott-user-submit" type="button"  value="找到id=king的刘备"  id="sg"  />
	</body>
	<!--Step1:导入jquery-->
	<script type="text/javascript" src="../../../js/jquery-1.4.1.js" ></script>
	<script>
	
		$(function(){
			$('#sg').click(function(){
				
				
				var length = $("#king").length;
				console.log(length);
				
				var lb = $("#king").html().trim();
				console.log(lb);
				
				 
				 $('#king').addClass('bg');
				
			});
		});
		
	</script>
</html>
